<?php
/**
 * Created by PhpStorm.
 * User: edmmss
 * Date: 2018/11/9
 * Time: 11:11
 */

namespace app\modules\factoryMethod\factory;

use app\modules\factoryMethod\vehicle\AbstractVehicle;

/**
 * Class AbstractFactoryMethod
 * @package app\modules\factoryMethod\factory
 */
abstract class AbstractFactoryMethod
{
    const TYPE_CHEAP = 'cheap';
    const TYPE_FAST = 'fast';

    /**
     * className
     *
     * @date   2018/11/9
     * @author edmmss
     * @param string $type
     * @return AbstractVehicle
     */
    abstract public function createVehicle(string $type): AbstractVehicle;

    /**
     * className
     *
     * @date   2018/11/9
     * @author edmmss
     * @param string $type
     * @return AbstractVehicle
     */
    public function create(string $type): AbstractVehicle
    {
        $object = $this->createVehicle($type);
        $object->setColor('red');

        return $object;
    }
}